<template>
  <div>
    <slot name="title"></slot>
    <div v-for="(item, index) in data" :key="index" class="select-item">
      <div class="select-line-icon option-drag">
        <i class="el-icon-s-operation" />
      </div>
      <el-input v-model="item.label" @input="setOptionLable(item, $event)" placeholder="请输入库名" size="small" />
      <el-input
        placeholder="请输入表名（多个表之间用，隔开）"
        size="small"
        :value="item.value"
        @input="setOptionValue(item, $event)"
      />
      <div class="close-btn select-line-icon" @click="removeSelectItem(index)">
        <i class="el-icon-remove-outline" />
      </div>
    </div>
    <div style="margin-left: 20px;text-align:left">
      <el-button style="padding-bottom: 0" icon="el-icon-circle-plus-outline" type="text" @click="addSelectItem">
        添加选项
      </el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  props: {
    data: Array,
  },
  components: {},
  data() {
    return {};
  },
  computed: {},
  mounted() {},
  methods: {
    removeSelectItem(index) {
      this.data.splice(index, 1);
    },
    addSelectItem() {
      this.data.push({
        label: "",
        value: "",
      });
    },
  },
  watch: {},
};
</script>
<style lang="scss" scoped>
//@import url(); 引入公共css类
.select-item {
  display: flex;
  border: 1px dashed #fff;
  box-sizing: border-box;
  & .close-btn {
    cursor: pointer;
    color: #f56c6c;
  }
  & .el-input + .el-input {
    margin-left: 4px;
  }
}
.select-item + .select-item {
  margin-top: 4px;
}
.select-item.sortable-chosen {
  border: 1px dashed #409eff;
}
.select-line-icon {
  line-height: 32px;
  font-size: 22px;
  padding: 0 4px;
  color: #777;
}
</style>
